export default {
	//时间倒推转换
	backTime(day) {
		if (day == 'all') {
			return {
				queryStartTime: uni.$u.timeFormat(new Date(-1), 'yyyy-mm-dd hh:MM:ss'),
				queryEndTime: uni.$u.timeFormat(false, 'yyyy-mm-dd hh:MM:ss')
			}
		}
		const now = new Date()
		const back = new Date(now.setDate(now.getDate() - day))
		let item = {
			queryStartTime: uni.$u.timeFormat(back, 'yyyy-mm-dd') + " 23:59:59",
			queryEndTime: uni.$u.timeFormat(false, 'yyyy-mm-dd hh:MM:ss')
		}
		// console.log(item)
		return item
	},
	//时间倒推数组
	backTimeArray() {
		let _array = []
		_array.push({
			checked: true,
			text: '今天',
			time: this.backTime(1)
		})
		_array.push({
			checked: false,
			text: '近7天',
			time: this.backTime(7)
		})
		_array.push({
			checked: false,
			text: '近一个月',
			time: this.backTime(30)
		})
		_array.push({
			checked: false,
			text: '近半年',
			time: this.backTime(183)
		})
		_array.push({
			checked: false,
			text: '全部',
			time: this.backTime("all")
		})
		return _array
	},
	//节点筛选转换
	tranferNode(array) {
		let temp = []
		let first = {
			checked: true,
			text: "全部",
			rootPartId: "",
			partLevel: ''
		}
		for (let i = 0; i < array.length; i++) {
			let item = {}
			// if (i == 0) {
			// 	item.checked = true
			// } else {
			item.checked = false
			// }
			item.text = array[i].partName
			item.rootPartId = array[i].partId
			item.partLevel = array[i].partLevel
			temp.push(item)
		}
		return [first, ...temp]
	}
}
